package com.jk.smartelderlycare.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jk.smartelderlycare.dto.SysUser;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.HashMap;
import java.util.List;

/**
 * @Description 添加描述
 * @Author hhk
 * @LastChangeDate 2024/11/5 15:56
 * @Version v1.0
 */
public interface SysUserMapper extends BaseMapper<SysUser> {
    /** 
     * @description: 用户列表后端分页查询
     * @param: [sysUser, page]
     * @return: com.baomidou.mybatisplus.core.metadata.IPage<com.jk.smartelderlycare.dto.SysUser>
     * @author hhk
     * @date: 2024/11/5 16:19
     */ 
    IPage<SysUser> findSysUserPaginationList(@Param(value = "sysUser") SysUser sysUser, Page<SysUser> page);

    /**
     * @description: 删除角色员工关联表
     * @param: [userId]
     * @return: void
     * @author hhk
     * @date: 2024/11/5 17:04
     */
    @Delete("delete from sys_user_role where user_id = #{userId}")
    void deleteSysUserRoleByUserId(Long userId);
    /**
     * @description: 新增员工角色关联表
     * @param: [roleMap]
     * @return: void
     * @author hhk
     * @date: 2024/11/5 17:22
     */
    void addSysUserAndRole(HashMap<String, Object> roleMap);
    /**
     * @description: 根据id查询用户信息
     * @param: [userId]
     * @return: com.jk.smartelderlycare.dto.SysUser
     * @author hhk
     * @date: 2024/11/5 18:42
     */
    SysUser findSysUserByUserId(Long userId);
    /** 
     * @description: 根据用户id删除
     * @param: [userId]
     * @return: void
     * @author hhk
     * @date: 2024/11/5 18:53
     */ 
    @Delete("delete from sys_user_role where user_id = #{userId}")
    void delUserRoleByUserId(Long userId);

    /**
     * @description: 状态修改
     * @param: [sysUser]
     * @return: void
     * @author hhk
     * @date: 2024/11/6 20:32
     */
    @Update("update sys_user set  status = #{status} where user_id = #{userId}")
    void updateStatusById(SysUser sysUser);
    /**
     * @description: 根据当前登陆人id查询
     * @param: [sysUser]
     * @return: com.jk.smartelderlycare.dto.SysUser
     * @author hhk
     * @date: 2024/11/11 11:25
     */
    List<SysUser> getSysUserByUsername(SysUser sysUser);

    /**
     * @description: 修改密码
     * @param: [sysUser]
     * @return: void
     * @author hhk
     * @date: 2024/11/11 11:03
     */
    @Update("update sys_user set   password=#{password} where user_id = #{userId}")
    void upSysUserByPassWord(SysUser sysUser);

}
